package com.example.rbac.controller.view;

import com.example.rbac.Exception.AuthException;
import com.example.rbac.uitls.ThreadUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by Administrator on 2017/9/25.
 */
@Controller
@RequestMapping("/user")
public class UserController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @RequestMapping("/list")
    @RequiresPermissions("user:view")
    public String UserList(){
        boolean state = SecurityUtils.getSubject().isPermitted("user:edit");
        logger.info("state={}", state);
        return "user/user-list";
    }


    @RequestMapping("/edit")
    public String editView(){
        return "user/user-add";
    }

    @RequestMapping("/update")
    public String update(){
        return "user/user-update";
    }


    @RequestMapping("/del")
    @RequiresPermissions("user:edit")
    public String delUser(){
        /*if (!SecurityUtils.getSubject().isPermitted("user:view")){
            return "/303";
        }*/
        return "user/user-del";
    }

    @RequestMapping("/test")
    public String test(){
        return "user/test";
    }
}
